﻿using System;
using System.Diagnostics;
using Xunit;

namespace MyDemo.ExamSubject
{
    /// <summary>
    /// 面试题3
    /// </summary>
    public class Subject3
    {
        /// <summary>
        /// 题目3
        /// </summary>
        [Fact]
        public void Test3()
        {
            B b = new B();
        }

        public class A 
        {
            public A()
            {
                PrintFields();
            }

            public virtual void PrintFields()
            {
            }
        }

        public class B : A
        {
            private int x = 1;
            private int y;

            public B()
            {
                y = -1;
                PrintFields();
            }

            public override void PrintFields()
            {
                Debug.WriteLine("x={0},y={1}", x, y);
            }
        }
    }
}